function NhanVien(data){
    this.id = data.id;
    this.Ten = data.TenNV
}
function PhongQL(data){
    this.MaPhong = data.MaPhong;
    this.Phong = data.Phong;
    this.Ngay = data.Ngay
}
function TaiSanQL(data){
    this.MaTS = data.MaTS;
    this.TenTS = data.TenTS;
    this.Ngay = data.Ngay
}
function PhieuNhapQL(data){
    this.MaTS = data.MaTS;
    this.TenTS = data.TenTS;
    this.SoLuong = data.SoLuong;
    this.Ngay = data.Ngay
}
function ViewModel(){
    var self = this;
    self.NhanViens = ko.observableArray();
    self.PhongQLs = ko.observableArray();
    self.TaiSanQLs = ko.observableArray();
    self.PhieuNhapQLs = ko.observableArray();
    self.NhanVienChon = ko.observable();
    self.TenChon = ko.observable();
    self.idChon = ko.observable();

    self.Show = function(){
        $("#Content").show()
        self.TenChon(self.NhanVienChon().Ten)
        self.idChon(self.NhanVienChon().id)
        $.getJSON("getQuanli.json?nvid=" + self.NhanVienChon().id, function(allData){
            var mappedQuanLi = $.map(allData, function(item){ return new PhongQL(item)});
            self.PhongQLs(mappedQuanLi);
        })
        $.getJSON("getCtPhong.json?nvid=" + self.NhanVienChon().id, function(allData){
            var mappedTS = $.map(allData, function(item){ return new TaiSanQL(item)});
            self.TaiSanQLs(mappedTS);
        })
        $.getJSON("getPhieuNhap.json?nvid=" + self.NhanVienChon().id, function(allData){
            var mappedPN = $.map(allData, function(item){ return new PhieuNhapQL(item)});
            self.PhieuNhapQLs(mappedPN);
            console.info(self.NhanVienChon())
        })
    };
    $.getJSON('getNhanVien.json', function (allData) {
        var mappedNhanViens = $.map(allData, function (item) { return new NhanVien(item) });
        self.NhanViens(mappedNhanViens);
    });
}